<template>
	<view>
		<u-subsection :list="list" :current="cur" @change="chane"></u-subsection>
		<view class="i1" v-for="item in all" @click="tonext(item.orderInfo.orderNo)">
			<image :src="'http://124.93.196.45:10001'+item.sellerInfo.imgUrl"></image>
			<view class="l2">
				<text>{{item.sellerInfo.name}}</text>
				<text>订单状态：{{item.orderInfo.status}}</text>
				<text>总计：{{item.orderInfo.amount}}￥</text>
				<text>订单提交时间：{{item.orderInfo.createTime}}</text>
				<text v-if="item.orderInfo.payTime">支付时间：{{item.orderInfo.payTime}}</text>
			</view>
		</view>
		<u-tabbar>
			<u-tabbar-item text="首页" icon="home" @click="tohome"></u-tabbar-item>
			<u-tabbar-item text="订单" icon="coupon-fill"></u-tabbar-item>
			<u-tabbar-item text="我的" icon="account" @click="tomy"></u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:['全部','待支付','待评价','退款'],
				cur:0,
				all:[],
				alllist:[]
			}
		},
		onLoad() {
			this.getall()
		},
		methods: {
			tohome(){
				uni.redirectTo({
					url:'/pages/other/takaway/takaway'
				})
			},
			tomy(){
				uni.redirectTo({
					url:'/pages/other/takaway/My/My'
				})
			},
			chane(index){
				this.cur=index
				if(this.cur===0){
					this.all=this.alllist
				}else if(this.cur===1){
					this.all=this.alllist.filter((item)=>item.orderInfo.status==='待支付')
				}else if(this.cur===2){
					this.all=this.alllist.filter((item)=>item.orderInfo.status==='待评价')
				}else{
					this.all=this.alllist.filter((item)=>item.orderInfo.status==='退款')
				}
			},
			getall(){
				this.api.get('/prod-api/api/takeout/order/list').then(res=>{
					this.all=res.data.rows
					this.alllist=res.data.rows
				})
			},
			tonext(order){
				uni.navigateTo({
					url:'/pages/other/takaway/indent/indentdetail/indentdetail?order='+order
				})
			}
		}
	}
</script>

<style lang="scss">
.i1{
	display: flex;
	border-bottom: 2px solid salmon;
	image{
		width: 150px;
		height: 125px;
		border-radius: 15px;
		margin-top: 15px;
	}
	.l2{
		display: flex;
		flex-direction: column;
		line-height: 30px;
		margin-left: 20px;
	}
}
</style>
